<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 编码
    // encodeURI()  可以编码中文, 特殊字符
    // encodeURIComponent()  可以编码中文, 特殊字符(编码范围更广)

    // 解码
    // decodeURI()  对encodeURI()编码的内容进行解码
    // decodeURIComponent()  对encodeURIComponent()编码的内容进行解码

    var str = "哈哈123456abcdef+-*/%,"

    var enStr1 = encodeURI(str);
    console.log(enStr1);

    var enStr2 = encodeURIComponent(str);
    console.log(enStr2);


    var str1 = decodeURI(enStr1);
    console.log(str1);

    var str2 = decodeURIComponent(enStr2);
    console.log(str2);

</script>

</html>